/* 
 * Header file for CmpdRTobject(compound RT object)
 * Programming by SochiX (http://sochix.ru)
 */

#ifndef _CMPD_RT_OBJECT_HPP
#define _CMPD_RT_OBJECT_HPP

#include <iostream>


#include "vector3D.hpp"
#include "ray.hpp"
#include "../graph/color.hpp"
#include "rt_object.hpp"
#include "material.hpp"
#include <vector>
#include <float.h>

//#include <math.h>

class CmpdRTobject : public RTobject
{
	private:
		
	public:
	std::vector<RTobject*> objectsList;
	RTobject* nearestObject; //pointer to nearest object for tracing

   	bool FindNearestIntersection(Ray&, double&);
	CmpdRTobject():RTobject(Point3D(0,0,0), Material(1.0,Color(0,0,0))) {nearestObject=NULL;}
	void Add(RTobject* object) {objectsList.push_back(object);};
	virtual bool Intersect(Ray& intersectRay, double& dist);
	virtual Color Trace(Ray&, Point3D, double&); 
	virtual	Vector3D GetNormalVect() {return nearestObject -> GetNormalVect();}
	virtual Material GetMaterial() {return nearestObject -> GetMaterial();}
	virtual std::string GetName() {return nearestObject->GetName();}
//	RTobject* operator->() const {std::cout<<"i'm in ->"; return nearestObject;};
};

#endif	/* _CMPD_RT_OBJECT_HPP */
